/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JanelaVitoria.java
 *
 * Created on Nov 25, 2011, 9:09:13 AM
 */
package gui.janelas;

import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import main.Main;

/**
 *
 * @author arthur
 */
public class JanelaVitoria extends JDialog {

    Frame pai;
    
    /** Creates new form JanelaVitoria */
    public JanelaVitoria(java.awt.Frame parent, boolean modal, String nomeJogador) {
        super(parent, modal);
        initComponents();
        
        pai = parent;
        
        int w = getSize().width;
        int h = getSize().height;
        int x = (parent.getWidth()-w)/2;
        int y = (parent.getHeight()-h)/2;

        setLocation(x, y);
        
        this.labelCampeao.setText(nomeJogador + " Venceu!");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        labelCampeao = new javax.swing.JLabel();
        botaoRecomecar = new javax.swing.JButton();
        botaoTrocarSala = new javax.swing.JButton();
        botaoSairJogo = new javax.swing.JButton();
        labelMensagem = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        labelCampeao.setFont(new java.awt.Font("Segoe UI", 1, 36));
        labelCampeao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/campeao.png"))); // NOI18N
        labelCampeao.setText("Jogador 1 Venceu");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 20, 0);
        getContentPane().add(labelCampeao, gridBagConstraints);

        botaoRecomecar.setFont(new java.awt.Font("Segoe UI", 1, 18));
        botaoRecomecar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/reiniciar.png"))); // NOI18N
        botaoRecomecar.setText("Recomeçar");
        botaoRecomecar.setMargin(new java.awt.Insets(10, 20, 10, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(botaoRecomecar, gridBagConstraints);

        botaoTrocarSala.setFont(new java.awt.Font("Segoe UI", 1, 18));
        botaoTrocarSala.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/trocar-sala.png"))); // NOI18N
        botaoTrocarSala.setText("Trocar de Sala");
        botaoTrocarSala.setMargin(new java.awt.Insets(10, 20, 10, 20));
        botaoTrocarSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clicarBotaoTrocarSala(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(botaoTrocarSala, gridBagConstraints);

        botaoSairJogo.setFont(new java.awt.Font("Segoe UI", 1, 18));
        botaoSairJogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/sair-jogo.png"))); // NOI18N
        botaoSairJogo.setText("Sair do Jogo");
        botaoSairJogo.setMargin(new java.awt.Insets(10, 20, 10, 20));
        botaoSairJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clicarBotaoSair(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(botaoSairJogo, gridBagConstraints);

        labelMensagem.setText("O que você gostaria de fazer?");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        getContentPane().add(labelMensagem, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void clicarBotaoSair(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clicarBotaoSair
        int resp = JOptionPane.showConfirmDialog(this, "Tem certeza?", "Sair do Armada", JOptionPane.OK_CANCEL_OPTION);
        
        if(resp == JOptionPane.OK_OPTION){
            System.exit(0);
        }
    }//GEN-LAST:event_clicarBotaoSair

    private void clicarBotaoTrocarSala(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clicarBotaoTrocarSala
        int resp = JOptionPane.showConfirmDialog(this, "Tem certeza?", "Trocar de Sala", JOptionPane.OK_CANCEL_OPTION);
        
        if(resp == JOptionPane.OK_OPTION){
            pai.dispose();
            this.dispose();
            
            Main.jogo.iniciarJanelaSalas();
        }
    }//GEN-LAST:event_clicarBotaoTrocarSala

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        JanelaVitoria janela = new JanelaVitoria(null, true, "Arthur");
        janela.setVisible(true);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoRecomecar;
    private javax.swing.JButton botaoSairJogo;
    private javax.swing.JButton botaoTrocarSala;
    private javax.swing.JLabel labelCampeao;
    private javax.swing.JLabel labelMensagem;
    // End of variables declaration//GEN-END:variables
}
